﻿using System.Web.Mvc;

using Gx.Common;
using Gx.ColdWarehouseErp.HelperClass;
using Gx.Bll.Role;
using Gx.Model;
using Gx.Model.Role;
using System.Collections.Generic;
using Gx.Bll.Manage;

namespace Gx.ColdWarehouseErp.Controllers
{
    public class HomeController : Controller//: BaseController
    {
        [AboutErrorAttributeMvc]
        [AuthorActionAttributeFilter]
        public ActionResult Index()
        {
            string menusList = new M_RolePageUrlInfoBll().GetRolePageUrljson();
            ViewData["menusList"] = menusList;
            return View();
        }

        public ActionResult Login()
        {
            return View();
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName">账号</param>
        /// <param name="userPass">密码</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult UserLogin(string userName, string userPass)
        {
            ReturnModel<string> m = new B_EmployeeInfoBll().UserLogin(userName, userPass);
            return Json(m);
        }


        [HttpPost]
        public ActionResult EditPassWord(string userPass)
        {
            ReturnModel m = new B_EmployeeInfoBll().EditPassWord(new Model.ViewModel.RestPassWordInput { EmpPwd = userPass });
            return Json(m);
        }


        [HttpPost]
        public ActionResult ExitLogin()
        {
            CookieHelper.RemoveCookie(LoginHelper.UserCookie);
            return Content(null);
        }


        [HttpPost]
        public ActionResult GetLoginCookieName()
        {
            string userCookieName = ConfigHelper.GetWebConfig("UserCookie");
            return Content(userCookieName);
        }
    }
}
